<template>
  <div>
    <banner></banner>
    <div class="questionsContent">
      <header>当前第2题/共8题</header>
      <p>2.你选择学校更看重那些方面？（多选）</p>
      <checkbox-group class="radioGroup"
        @change="getRadioValue"
      >
        <label
          @click="reasonMsg(index)"
          class="radio"
          v-for="(item,index) in subData"
          :index="index"
          :key="index"
        >
          <checkbox :value="item.value" />
          <span>{{item.value}}</span>
        </label>
      </checkbox-group>
      <button @click="PlusIndex" type="primary">下一题</button>
    </div>
  </div>
</template>

<script>
import banner from "@/components/questionBanner.vue";
import Vue from "vue"
export default {
  data() {
    return {
      subData: [
        { value: "A.教学质量" },
        { value: "B.就业保障" },
        { value: "C.品牌知名度" },
        { value: "D.课程设置" },
        { value: "E.口碑美誉度" },
        { value: "F.办学规模" },
        { value: "G.校园环境" },
        { value: "H.住宿条件" },
        { value: "I.性价比" },
        { value: "Q.其他" }
      ],
      currentIndex: []
    };
  },
  components: {
    banner
  },
  methods: {
    PlusIndex() {
      if (this.currentIndex.length < 1) {
        wx.showToast({
          title: "不能为空",
          duration: 2000,
          icon: "none"
        });
      } else {
        wx.navigateTo({ url: "../questionThree/main" });
      }
    },
    reasonMsg(index) {
      if (this.currentIndex.indexOf(index) == -1) {
        this.currentIndex.push(index);
        console.log(this.currentIndex);
      } else {
        this.currentIndex.splice(index, 1);
        console.log(this.currentIndex);
      }
    },
    getRadioValue(e) {
      Vue.prototype.advantage = e.mp.detail.value;
    }
  },
  created() {
    console.log(this.currentIndex);
  },
  onLoad() {

  }
};
</script>

<style scoped>
</style>
